import request from '@/utils/request-unimall'
import Qs from 'qs'

export function categorySecondLevelTree() {
  return request({
    method: 'get',
    url: "/web/admin-category/category-secone-level-tree",
    params: {
      // _gp: 'admin.category',
      // _mt: 'categorySecondLevelTree'
    }
  })
}

export function categoryTree(zzjgId) {
  if(zzjgId == null || zzjgId == ''){
    zzjgId = 1;
  }
  return request({
    method: 'get',
    url: "/web/admin-category/category-tree?zzjgId="+zzjgId,
    params: {
      // _gp: 'admin.category',
      // _mt: 'categoryTree'
    }
  })
}

export function listCategory(query) {
  return request({
    method: 'get',
    url: "/web/admin-category/list",
    params: {
      // _gp: 'admin.category',
      // _mt: 'list',
      ...query
    }
  })
}

export function createCategory(data) {
  return request({
    method: 'post',
    url: "/web/admin-category/create",
    data: Qs.stringify({
      // _gp: 'admin.category',
      // _mt: 'create',
      ...data
    })
  })
}

export function updateCategory(data) {
  return request({
    method: 'post',
    url: "/web/admin-category/update",
    data: Qs.stringify({
      // _gp: 'admin.category',
      // _mt: 'update',
      ...data
    })
  })
}

export function deleteCategory(id) {
  return request({
    method: 'post',
    url: "/web/admin-category/delete",
    params: {
      // _gp: 'admin.category',
      // _mt: 'delete',
      id: id
    }
  })
}
